'''
@Project ：hdcms-scripts
@File    ：create_live_config.py
@IDE     ：PyCharm
@Author  ：朱广杰
@Date    ：2024/11/26 11:45
'''


from script.api.base_api import BaseCallbackApi, BaseCapiApi, BaseCmsv2Api
from common.time_util import get_now_timestamp, get_next_2min_datetime
from common.FILE_PATH import load_yaml_file, BASE_DIR, read_excel, get_config_value


# 获取课程的直播间信息
class AddPopApi(BaseCmsv2Api):
    def __init__(self, pop_type: int,course_id: str, chatroom_id: str, collect_course_info:list, extra_info: dict):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live/add_pop'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "course_id": course_id,
            "title": "新增弹窗测试",
            "pop_type": pop_type,
            "open_time": get_next_2min_datetime(),
            "sku_mode": "yxs",
            "collect_course_info": collect_course_info,
            "extra_info": extra_info
        }


class AddInteractApi(BaseCmsv2Api):
    def __init__(self, course_id: str, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live_interact/add_interact'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "content": "新增呼应time测试",
            "keyword": "",
            "duration": 200,
            "interact_type": 0,
            "open_time": get_next_2min_datetime(),
            "target_course_id": course_id,
            "sku_mode": "yxs"
        }


class UpdateInteractStateApi(BaseCmsv2Api):
    def __init__(self, interact_id: int):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live_interact/update_interact_state'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "interact_id": interact_id,
            "interact_state": 1,
            "sku_mode": "yxs"
        }
class GetInteractApi(BaseCmsv2Api):
    def __init__(self, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live_interact/get_interact_list'
        self.method = 'get'
        self.params = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id
        }
class AddPrizeApi(BaseCmsv2Api):
    def __init__(self, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/prize/add_prize'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "prize_id": 0,
            "title": "红包测试",
            "prize_desc": "红包测试",
            "prize_type": 0,
            "dist_type": 1,
            "rob_type": 1,
            "total_yanzhi": 100,
            "single_yanzhi": 0,
            "prize_image": "",
            "sms_words": "",
            "prize_num": 10,
            "dist_time": "2024-12-26 00:00:00",
            "view_group": 0,
            "view_phone_file_url": "",
            "user_group": 0,
            "phone_file_url": ""
        }


class UpdatePrizeApi(BaseCmsv2Api):
    def __init__(self, prize_state: int, prize_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/prize/update_prize_state'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "prize_id": prize_id,
            "prize_state": prize_state # 0:关闭 1:开始
        }


class AddChoiceQuestionApi(BaseCmsv2Api):
    def __init__(self, course_id:str, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live_interact/add_choice_question'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "course_id": course_id,
            "chatroom_id": chatroom_id,
            "title": "答题测试",
            "option_type": 0,
            "option_list": "[{\"index\":0,\"content\":\"A\"},{\"index\":1,\"content\":\"B\"},{\"index\":2,\"content\":\"C\"},{\"index\":3,\"content\":\"D\"},{\"index\":4,\"content\":\"E\"},{\"index\":5,\"content\":\"F\"}]",
            "right_answer": "",
            "duration": 200,
            "open_time": "",
            "question_type": 1,
            "group_no": 1,
            "is_display_chatroom": 1
        }
class GetChoiceQuestionApi(BaseCmsv2Api):
    def __init__(self, chatroom_id: str, course_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/live_interact/get_choice_question_list'
        self.method = 'get'
        self.params = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "course_id": course_id
        }
class GetPrizeApi(BaseCmsv2Api):
    def __init__(self, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/prize/get_prize_list'
        self.method = 'get'
        self.params = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id
        }
class AddQuestionApi(BaseCmsv2Api):
    def __init__(self, course_id: str, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/course/question/update_question'
        self.method = 'post'
        self.json = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "course_id": course_id,
            "is_nps": 1,
            "need_update_score": 0,
            "belong_to_course": "bb688f648776b6437fd4064834ff70a2",
            "belong_to_course_title": "nps弹窗测试",
            "stem": "nps弹窗测试",
            "teacher_id": "21169a98a7108c0447342f8eaad60f7c",
            "teacher_name": "潘育新",
            "duration": 200,
            "autopush_time": "2024-12-10 00:00:00",
            "options": [],
        }
class GetQuestionApi(BaseCmsv2Api):
    def __init__(self, course_id: str, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/course/question/get_question_list'
        self.method = 'get'
        self.params = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "course_id": course_id
        }
class PushQuestionApi(BaseCmsv2Api):
    def __init__(self, question_id: str,course_id: str, chatroom_id: str):
        super().__init__()
        self.common = load_yaml_file('/config/common.yml')
        self.url = f'{self.host}/course/question/push_question'
        self.method = 'get'
        self.params = {
            "token": self.common['token'],
            "admin_id": self.common['admin_id'],
            "timestamp": get_now_timestamp(),
            "_ignore_sign": "_hundun",
            "chatroom_id": chatroom_id,
            "course_id": course_id,
            "question_id": question_id
        }
if __name__ == '__main__':
    aa = AddInteractApi(course_id='bb688f648776b6437fd4064834ff70a2', chatroom_id='133248').send()
    print(aa.json())


